/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    const { INTEGER, STRING, DATE, TEXT, FLOAT } = Sequelize;
    await queryInterface.createTable(
      "member",
      {
        id: {
          type: INTEGER,
          primaryKey: true,
          autoIncrement: true,
          comment: "主键ID"
        },
        memname: {
          type: STRING(30),
          allowNull: false,
          defaultValue: "",
          unique: true,
          comment: "会员名称"
        },
        memlevel: {
          type: STRING(30),
          allowNull: false,
          defaultValue: "",
          comment: "会员等级"
        },
        discount: {
          type: FLOAT(5, 2),
          allowNull: false,
          defaultValue: 0,
          comment: "会员折扣"
        },
        lowpoint: {
          type: INTEGER,
          allowNull: false,
          defaultValue: 200,
          comment: "最低积分"
        },
        highpoint: {
          type: INTEGER,
          allowNull: false,
          defaultValue: 1000,
          comment: "最高积分"
        },
        desc: {
          type: TEXT,
          allowNull: false,
          defaultValue: "",
          comment: "会员相关"
        },
        creator: {
          type: STRING(30),
          allowNull: false,
          defaultValue: "",
          comment: "创建人"
        },
        created_time: DATE,
        updated_time: DATE
      },
      {
        engine: "InnoDB",
        // autoIncrement: 10, // 锁定从哪开始递增
        charset: "utf8mb4",
        collate: "utf8mb4_general_ci"
      }
    );
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable("member");
  }
};
